#include <pic.h>
#include <OSA.h>

unsigned char counter;


//------------------------------------------------------------------------------
void Task_T1 (void)
{
    for (;;)
    {
        OS_Bsem_Set(0);
        counter++;
        OS_Yield();
        counter++;
        OS_Bsem_Wait(2);
    }
}


//------------------------------------------------------------------------------
void Task_T2 (void)
{
    for (;;)
    {
        OS_Bsem_Set(1);
        counter++;
        OS_Yield();
        counter++;
        OS_Bsem_Wait(4);
    }
}


//------------------------------------------------------------------------------
void Task_T3 (void)
{
    for (;;)
    {

        OS_Bsem_Set(2);
        counter++;
        OS_Yield();
        counter++;
        OS_Bsem_Wait(4);


    }
}


//------------------------------------------------------------------------------
void main (void)
{
    OS_Init();
    OS_Task_Create(1, Task_T1);
    OS_Task_Create(1, Task_T2);
    OS_Task_Create(1, Task_T3);


    for (;;)
    {
        asm(" CLRWDT ");
        OS_Sched();
    }
}

